<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>角色信息表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link th:href="@{../assets/css/page.css}" rel="stylesheet"/>
    <link th:href="@{../assets/libs/bootstrap-duallistbox/src/bootstrap-duallistbox.css}" rel="stylesheet"/>
    <script type="text/javascript" th:src="@{../assets/libs/jquery/dist/jquery.js}"></script>
    <script type="text/javascript" th:src="@{../assets/libs/bootstrap-duallistbox/src/jquery.bootstrap-duallistbox.js}"></script>
    <script type="text/javascript" th:src="@{../assets/libs/bootstrap/dist/js/bootstrap.js}"></script>
    <script type="text/javascript" th:src="@{../assets/libs/nice-validator/dist/jquery.validator.js}"></script>
    <script type="text/javascript" th:src="@{../assets/libs/nice-validator/dist/local/zh-CN.js}"></script>
    <!--[if lt IE 9]>
    <script th:src="@{../assets/js/html5shiv.js}"></script>
    <script th:src="@{../assets/js/respond.min.js}"></script>
    <![endif]-->
    <script type="text/javascript" th:inline="javascript">
        $(function () {
            //ajax动态加载select
            $.ajax({
                url:'../operation/pageQuery',
                type:"get",
                async:false,
                dataType:"json",
                success:function (result) {
                    var html="";
                    $.each(result.rows,function (i,item) {
                        if(null != [[${item.ccode}]]){
                            var bool = isContains([[${item.ccode}]],item.icode);
                            if(bool){
                                html += "<option value="+item.icode+" selected="+bool+">"+item.cname+"</option>";
                            }else{
                                html += "<option value="+item.icode+">"+item.cname+"</option>";
                            }
                        } else{
                            html += "<option value="+item.icode+">"+item.cname+"</option>";
                        }

                    });
                    $("#ccode").html(html);
                },
                error:function (error) {

                }
            });

            var demo2 = $('#ccode').bootstrapDualListbox({//生成bootstrapDualListbox
                moveAllLabel: "全部选中",
                removeAllLabel: "全部移除",
                infoTextEmpty: "没有记录",
                infoText: "{0}条记录",
                selectedListLabel: "已拥有权限",
                nonSelectedListLabel: "未拥有权限",
                preserveSelectionOnMove: 'moved',
                moveOnSelect: true,
                nonSelectedFilter: '',
                infoTextFiltered: '<span class="label label-warning">从 {1} 条数据中查询到 {0} 条数据</span>'
            });


           /* $("#demoform").submit(function () {
                alert($('[name="ccode"]').val());
            });*/
        });
        //是否包含字符串
        function isContains(str, substr) {
            return str.indexOf(substr) >= 0;
        }
        function subSubmitHandler(){
            $('[name="ccode"]').val($('[name="ccodeArr"]').val());
            $('[name="ccodeArr"]').val("");
        }
    </script>
</head>
<body>
<div id="main" role="main">
    <div class="tab-content tab-addtabs">
        <div id="content">
            <div class="row">
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <div class="content">
                        <form id="edit-form" action="./editItem" method="post">
                            <input type="hidden" name="iid" th:value="${item.iid}"/>
                            <input type="hidden" name="crolename" th:value="${item.crolename}"/>
                            <input type="hidden" name="cname" th:value="${item.cname}"/>
                            <input type="hidden" name="ccode"/>
                            <select multiple="multiple" size="15" name="ccodeArr" id="ccode">

                            </select>
                            <br/>
                            <!--<input id="showValue" type="button" value="显示选中"/>-->
                            <!--<button type="submit" class="btn btn-default btn-block">提交</button>-->
                            <div class="form-group">
                                <label class="control-label col-xs-12 col-sm-2"></label>
                                <div class="col-xs-12 col-sm-8 text-center">
                                    <button type="submit" class="btn btn-success btn-embossed">确定</button>
                                    <button type="button" class="btn btn-warning btn-embossed" onclick="onCloseLayer()">关闭</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" th:src="@{../assets/libs/toastr/toastr.js}"></script>
<script type="text/javascript" th:src="@{../assets/libs/layer/src/layer.js}"></script>
<script type="text/javascript" th:src="@{../assets/libs/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js}"></script>
<script type="text/javascript" th:src="@{../assets/libs/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js}"></script>
<script type="text/javascript" th:src="@{../assets/js/page.js}"></script>

</body>
</html>

